# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=gnss-share
pkgver=0.4
pkgrel=3
pkgdesc="GNSS location provider, supporting multiple concurrent clients"
url="https://gitlab.com/postmarketOS/gnss-share"
arch="all"
license="GPL-3.0-or-later"
makedepends="go"
subpackages="$pkgname-openrc $pkgname-tools"
source="https://gitlab.com/postmarketOS/gnss-share/-/archive/$pkgver/gnss-share-$pkgver.tar.gz"

export GOMODCACHE="$srcdir/go"
export GOFLAGS="$GOFLAGS -modcacherw"
export CGO_ENABLED=0

build() {
	go build -v -ldflags="-s -w" -o gnss-share ./cmd/gnss-share
	go build -v -ldflags="-s -w" -o stmctl ./cmd/stmctl
}

check() {
	go test ./...
}

package() {
	install -Dm755 "gnss-share" \
		"$pkgdir/usr/bin/gnss-share"
	install -Dm755 "stmctl" \
		"$pkgdir/usr/bin/stmctl"

	install -Dm644 "gnss-share.conf" \
		"$pkgdir/etc/gnss-share.conf"

	install -Dm755 "openrc/gnss-share.initd" \
		"$pkgdir/etc/init.d/gnss-share"
	install -Dm755 "openrc/gnss-share.confd" \
		"$pkgdir/etc/conf.d/gnss-share"
}

tools() {
	amove usr/bin/stmctl
}

sha512sums="
9e0a4c5e09a4ed0741de2232f8a9ec44530e76359c0d73c698827e18e05bd7794aa8fa6112e5301bf7a5cfc24a2647135acda133eb67fdd1528976acc9488c3e  gnss-share-0.4.tar.gz
"
